home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / C++ A'Link Files / 1990 / Jul 90 / CPlus.Dev$ 7⁄27⁄90 / 0161-"overloading" fields-Jul90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  1.1 KB  |  40 lines  |  [TEXT/GEOL]

  1. Item    8815202                         27-July-90        08:21PDT
  2.  
  3. From:   DEREK                           White, Derek
  4.  
  5. To:     CPLUS.DEV$                      C++ Interest List--Developers
  6.         CPLUS.APPLE$                    C++ Interest List--Apple Employees
  7.  
  8. Sub:    "overloading" fields?
  9.  
  10. I've got C++ programming style question:
  11.  
  12.     Should you "overload" field names in a derived class?
  13.  
  14. I was playing with C++ to see if you could override static functions, then I
  15. looked at static class variables.  Then for fun (I never thought it was
  16. possible), I tried overloading a field name and it worked.  Note that
  17. everything is public:
  18.  
  19. class TShape {
  20.   public:
  21.     TShape(void);
  22.     static int gStatic;
  23.     static void foo();
  24.     intfDum, fDum2;
  25. };
  26.  
  27. class TRect: public TShape {
  28.   public:
  29.     TRect(void);
  30.     double fDum;            //***you CAN "overload" fields***
  31.     static int gStatic;     //you can "overload" static vars
  32.     static void foo(int);   //you can "overload" static funcs
  33. };
  34.  
  35. Does anyone take advantage of this?  Any arguments pro or con?
  36. - Derek White
  37.   ATG East/Columbia
  38.   Apple Computer
  39.  
  40.